package cn.net.msg.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import cn.net.msg.dao.MemberDao;
import cn.net.msg.model.ReturnPointBean;
import cn.net.msg.model.TbFavourite;
import cn.net.msg.model.TbUser;
import cn.net.msg.service.base.Order;

@Component("memberService")
public class MemberService {

    @Resource(name="memberDao")
    private MemberDao dao;

    @Transactional
    public TbUser checkLogin(String userNameOrEmail, String password){
        return dao.checkLogin(userNameOrEmail, password);
    }

    @Transactional
    public void updateLoginTime(TbUser tbUser){
        dao.updateLoginTime(tbUser);
    }

    @Transactional
    public boolean isExsitName(String name){
        return dao.isExsitName(name);
    }

    @Transactional
    public boolean isExsitEmail(String email){
        return dao.isExsitEmail(email);
    }

    @Transactional
    public void saveMember(TbUser tbUser){
        dao.saveUser(tbUser);
    }

    @Transactional
    public ReturnPointBean getUserPoint(long userid){
        return dao.getUserPoint(userid);
    }

    @Transactional
    public int deleteUser(long id){
        return dao.deleteUser(id);
    }

    @Transactional
    public TbUser find(long userid){
        return dao.find(userid);
    }

    @Transactional
    public void update(TbUser tbUser){
        dao.update(tbUser);
    }

    @Transactional
    public void uploadUserPoints(Map<String,Object> map){
        dao.uploadUserPoints(map);
    }

    @Transactional
    public void updateUserPassword(String email,String password){
        dao.updateUserPassword(email,password);
    }

    @Transactional
    public List<TbFavourite> getUserFavouriteForList(int firstIndex,
            int maxResult,List<HashMap<String,Object>> queryParams, Order order, String propertyName){
        return dao.getUserFavouriteForList(firstIndex, maxResult, queryParams, order, propertyName);
    }
}
